In the previous steps of the project we built a complete compiler for Tool \footnote{http://lara.epfl.ch/dokuwiki/cc09:tool}, a simplified object oriented language based on Java. The Tool compiler is designed to generate bytecode and any Tool program can therefore be run on the JVM.

Our compiler follows the general trends for compilers and is thus composed of several parts : a lexer, a parser, a semantic analyzer and a code generator.
The lexer reads the file given by the programmer, removes whitespaces, comments and creates the tokens. It also checks that identifiers, numbers and keywords are well-formed (\textit{i.e.} composed of valid characters.)
These tokens are then read by the parser, which checks that the program is correct in respect with Tool's grammar. Provided the program is correct, the parser creates its corresponding abstract syntax tree.
The analyzer will then be passed the AST for symbol analysis and type checking. 
If the program reaches this state, the compiler can safely generate the corresponding Java bytecode. An helper library, Cafebabe\footnote{http://lara.epfl.ch/dokuwiki/compilation:cafebabe} is used for this purpose. 


For the last free lab, we chose to extend Tool with exceptions support, pretty much like in Java. This extension includes support for \textsf{\small try catch} and possibly \textsf{\small finally} blocks, \textsf{\small throw} statements and the possibility for the programmer to extends the exception hierarchy.

Such an extension obviously implies extensions to TOOL's grammar (see chapter \ref{ToolGrammarExtension}), but also modifications of each parts of the compiler, from the lexer to the code generator (see chapter \ref{Implementation}). 
Modifications to the \textsc{Cafebabe} library were also needed. In particular, we had to modify preexisting methods and add others one. \textit{E.g.} we had to modify the \textsf{\small setHeight} method to take the exception handlers into account when computing the stack size, and we added the \textsf{\small addHandler} method so as to be able to add exception handlers in the exception table of a class file.

In order to allow programmers to define new exceptions, we also created a brand new root exception for TOOL, called \textsf{\small ToolException}. \textsf{\small ToolException} is defined in Java and its type is known by the compiler.
This implies that the JVM needs to know where ToolException.class is located when a program using exceptions is executed. 
When a programmer wants to define a new exception, that exception needs to be a subclass of \textsf{\small ToolException}.
